package com.ouc.pampas;
import java.io.FileNotFoundException;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class PageRender
{
  @Autowired
  protected HandlebarsEngine handlebarsEngine;
  
  public String render(String domain, String path, Map<String, Object> context)
  {
    return naiveRender(path, context);
  }
  
  protected String naiveRender(String path, Map<String, Object> context)
  {
    context.put("_PATH_", path);
    try
    {
      return this.handlebarsEngine.execPath(path, context, false);
    }
    catch (FileNotFoundException e)
    {
      e.printStackTrace();
      return "page not found";
    }
  }
}
